﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace haunstm_test_windows_forms
{
    public partial class frmWebBrowser : Form
    {
        public frmWebBrowser()
        {
            InitializeComponent();
        }

        private Uri LocationRelativeToTheApplicationInstallDirectory()
        {
            return new Uri(AppDomain.CurrentDomain.BaseDirectory);
        }

        private string ApacheSoftWareLicenseDocument()
        {
            string apacheSoftWareLicenseDocument = "";
            try
            {
                using (StreamReader sr = new StreamReader(@"Resources\Apache Software License, Version 2.0.txt"))
                {
                    apacheSoftWareLicenseDocument = sr.ReadToEnd();

                }
            }
            catch (Exception e)
            {
                apacheSoftWareLicenseDocument = "The file Apache Software License, Version 2.0.txt could not be read:" +
                e.Message;
            }
            return apacheSoftWareLicenseDocument;
        }
        private string ApplicationInfo()
        {
            var appInfo = "<html>" +
                            "  <head>" +
                            "  	    <title>itConnect - Disclaimer</title>" +
                            "       <style>" +
                            "           body" +
                            "           {" +
                            "               font-family: Arial, Helvetica, Sans-Serif;" +
                            "               font-size: 50%;" +
                            "               color: #141414;" +
                            "               background-color: #BFBFBF;" +
                            "           }" +
                            "       </style>" +
                            "       <script type=\"text/javascript\">" +
                            "           <!--" +
                            "               function toggle_visibility(id) {" +
                            "               var e = document.getElementById(id);" +
                            "               if(e.style.display == 'block')" +
                            "                   e.style.display = 'none';" +
                            "               else" +
                            "                   e.style.display = 'block';" +
                            "               }" +
                            "           //-->" +
                            "       </script>" +
                            "  </head>" +
                            "  <body>" +
                            "  	<h1>Info</h1>" +
                            "  	<h2>Open Source projects included:</h2>" +
                            "  	<ul>" +
                            "  		<li>" +
                            "  			<a href=\"http://logging.apache.org/log4net/\" target=\"_blank\">log4net&trade;</a> <small>(Licensed under the <a href=\"" + "Apache%20Software%20License,%20Version%202.0.txt" + "\")>Apache Software License, Version 2.0</a>)</small>" +
                            "  		</li>" +
                            "  	</ul>" +
                            "  	<h2>Disclaimer</h2>" +
                            "  	<p>IT Automation AB is not responsible under any circumstances for direct, indirect, unexpected damage or consequent damage that is caused by this software.</p>" +
                            "  	<br />" +
                            "  	<small>Copyright &copy; 2013 IT Automation AB." +
                            "          <br />" +
                            "  	    All rights reserved." +
                            "  	</small>" +
                            "   <p><cite>" + ApacheSoftWareLicenseDocument().Replace("\n","</br>") + "</cite></p>" +
                            "  </body>" +
                            "</html>";


            return appInfo;

        }

    private void frmWebBrowser_Load(object sender, EventArgs e)
    {
        webInfo.DocumentText = ApplicationInfo();
    }
       }
}
